<?php
session_start();

function utf8Substr($str, $from, $len)
{
return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
'$1',$str);
} 
//包含数据库连接文件
include('system/db/conn.php');
//setcookie("hasvalues","");
if(!isset($_COOKIE["hasvalues"])){ //如果没有设置cookie
  $sub_area_query = mysql_query("select *,count(*) as total from do_area  order by sort desc limit 4 ");
  $res = mysql_fetch_array($sub_area_query);
  $count = $res['total'];
  if($count > 0){
    setcookie("hasvalues", "true", time()+3600*24*30);//30天cookie过期
    //setcookie("hasvalues", "true", time()+3600*24*30);//30天cookie过期
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>外卖网365</title>
<link href="style/css.css" rel="stylesheet" type="text/css">
<script src="js/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="js/jquery.blockUI.js" type="text/javascript"></script>

<script type="text/javascript"> 

function suppliername(thisName){

$("#suppliernamesubmit").val(thisName);
 document.formx1.submit();
}
var sendPhone="";
function phoneCheck(){

var yanzhengma=$("#yanzhengma").val();
//
if(yanzhengma==""){
    alert("请输入验证码!");
  }else{

    $.ajax({ 
    type:'post', //传送的方式,get/post 
    url:'phonecheckAjax.php', //发送数据的地址 
    cache:'true',  
    data:'phonecheck='+yanzhengma,
    datatype:"text",
    success:function(data) 
    { 
      
     if(data=="yes"){
      
     	 $.ajax({ 
    type:'post', //传送的方式,get/post 
    url:'sendupdatePass.php', //发送数据的地址 
    cache:'true',  
    data:'phonecheck=2',
    datatype:"text",
    success:function(data) 
    { 
    	var hi=data.split(",");
    	if(hi[0]=="yes"){

		$.ajax({ 
               type:'post', //传送的方式,get/post 
               url:'post_mt1.php', //发送数据的地址 
               cache:'false', 
               data:'name='+sendPhone+"&sendValue="+"您的重置密码为:"+hi[1],  
              success:function(data) 
                { 
      
                }
            });


    		alert("成功重置，密码会以短信形式发送给您");


    	}else if(hi[1]=="no"){
    		alert("重置密码失败");
    	}

    } 
  }); 





     
     }else if(data=="no"){
     alert("验证码错误");

     }else{
      alert("验证码错误");
     }
    } 
  }); 

  }


//



}



var wait=60;

function time(o) {
        if (wait == 0) {
            o.removeAttribute("disabled");           
            o.value="发送验证码";
            wait = 60;
            o.className="resend-a";
        } else {
         o.className="resend-a2";
            o.setAttribute("disabled", true);
            o.value="重新发送(" + wait + ")";
            wait--;
            setTimeout(function() {
                time(o)
            },
            1000)
        }
}
function sendSMS() //点击提交留言ajax显示
{ 
  
  var zhanghao=$("#userzhanghao").val();

  $.ajax({ 
    type:'post', //传送的方式,get/post 
    url:'getUsername.php', //发送数据的地址 
    cache:'false', 
    data:'zhanghao='+zhanghao, 
    datatype:"text",
    success:function(data) 
    { 
      var hi=data.split(",");
      if(hi[0]=="success"){
      	sendPhone=hi[1];
        $.ajax({ 
               type:'post', //传送的方式,get/post 
               url:'post_mt.php', //发送数据的地址 
               cache:'false', 
               data:'name='+hi[1], 
              success:function(data) 
                { 
      				
                }
            })

      }else{

        alert("该账号不存在");
      }

    }
  });


  
/*   */

  time(document.getElementById("reSend"));
} 


function forgetPass(){
   //给box_btn绑定一个鼠标点击的事件
  $.blockUI({    //当点击事件发生时调用弹出层
    message: $('#loginbox3'),    //要弹出的元素box
    css: {    //弹出元素的CSS属性
      border:'5px solid #334343',
      textAlign: 'left',
    width: '490px',
    top:  ($(window).height() - 290) /2 + 'px', 
      left: ($(window).width() - 490) /2 + 'px', 
    cursor: 'auto'
         },
    overlayCSS: {
    opacity: '0.7' 
              }
   });
  $('.blockOverlay').attr('title','单击关闭').click($.unblockUI);   //遮罩层属性的设置以及当鼠标单击遮罩层可以关闭弹出层
  $('.close').click($.unblockUI);  //也可以自定义一个关闭按钮来关闭弹出层
}


$(function(){ 
//Default Action 
  $(".tab_content").hide(); //Hide all content 
  $("ul.tabs li:first").addClass("active").show(); //Activate first tab 
  $(".tab_content:first").show(); //Show first tab content 
  //On Click Event 
  $("ul.tabs li").click(function() { 
    $("ul.tabs li").removeClass("active"); //Remove any "active" class 
    $(this).addClass("active"); //Add "active" class to selected tab 
    $(".tab_content").hide(); //Hide all tab content 
    var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
    $(activeTab).fadeIn(); //Fade in the active content 
    return false; 
  }); 
}); 
</script> 
<script type="text/javascript"> 
$(function(){
  var mimacheck=$("#mimacheck").val();
  if(mimacheck==1){
       //给box_btn绑定一个鼠标点击的事件
  $.blockUI({    //当点击事件发生时调用弹出层
    message: $('#loginbox'),    //要弹出的元素box
    css: {    //弹出元素的CSS属性
      border:'5px solid #334343',
      textAlign: 'left',
    width: '490px',
    top:  ($(window).height() - 290) /2 + 'px', 
      left: ($(window).width() - 490) /2 + 'px', 
    cursor: 'auto'
         },
    overlayCSS: {
    opacity: '0.7' 
              }
   });
  $('.blockOverlay').attr('title','单击关闭').click($.unblockUI);   //遮罩层属性的设置以及当鼠标单击遮罩层可以关闭弹出层
  $('.close').click($.unblockUI);  //也可以自定义一个关闭按钮来关闭弹出层


  $("#passerrorShow").css("display","block");
  }


var mimacheck1=$("#mimacheck1").val();
  if(mimacheck1==1){
       //给box_btn绑定一个鼠标点击的事件
  $.blockUI({    //当点击事件发生时调用弹出层
    message: $('#loginbox1'),    //要弹出的元素box
    css: {    //弹出元素的CSS属性
      border:'5px solid #334343',
      textAlign: 'left',
    width: '490px',
    top:  ($(window).height() - 290) /2 + 'px', 
      left: ($(window).width() - 490) /2 + 'px', 
    cursor: 'auto'
         },
    overlayCSS: {
    opacity: '0.7' 
              }
   });
  $('.blockOverlay').attr('title','单击关闭').click($.unblockUI);   //遮罩层属性的设置以及当鼠标单击遮罩层可以关闭弹出层
  $('.close').click($.unblockUI);  //也可以自定义一个关闭按钮来关闭弹出层


  $("#passerrorShow1").css("display","block");
  }

  $('#login').click(function(){   //给box_btn绑定一个鼠标点击的事件
  $.blockUI({    //当点击事件发生时调用弹出层
    message: $('#loginbox'),    //要弹出的元素box
    css: {    //弹出元素的CSS属性
      border:'5px solid #334343',
      textAlign: 'left',
  	width: '490px',
  	top:  ($(window).height() - 290) /2 + 'px', 
      left: ($(window).width() - 490) /2 + 'px', 
  	cursor: 'auto'
         },
    overlayCSS: {
  	opacity: '0.7' 
  	          }
   });
  $('.blockOverlay').attr('title','单击关闭').click($.unblockUI);   //遮罩层属性的设置以及当鼠标单击遮罩层可以关闭弹出层
  $('.close').click($.unblockUI);  //也可以自定义一个关闭按钮来关闭弹出层
/*  $("#alllogin").attr("action","login.php");*/

  });
  
$('#shoplogin').click(function(){   //给box_btn绑定一个鼠标点击的事件
  $.blockUI({    //当点击事件发生时调用弹出层
    message: $('#loginbox1'),    //要弹出的元素box
    css: {    //弹出元素的CSS属性
      border:'5px solid #334343',
      textAlign: 'left',
    width: '490px',
    top:  ($(window).height() - 290) /2 + 'px', 
      left: ($(window).width() - 490) /2 + 'px', 
    cursor: 'auto'
         },
    overlayCSS: {
    opacity: '0.7' 
              }
   });
  $('.blockOverlay').attr('title','单击关闭').click($.unblockUI);   //遮罩层属性的设置以及当鼠标单击遮罩层可以关闭弹出层
  $('.close').click($.unblockUI);  //也可以自定义一个关闭按钮来关闭弹出层
  // $("#alllogin").attr("action","login-shop.php");
  });


});

function InputCheck(LoginForm)
{
  if (LoginForm.username.value == "")
  {
    alert("请输入用户名!");
    LoginForm.username.focus();
    return (false);
  }
  if (LoginForm.password.value == "")
  {
    alert("请输入密码!");
    LoginForm.password.focus();
    return (false);
  }
}

</script>
<?php
$area_query = mysql_query("select name from do_area where city_id=16 and pid = 0");

?> 
</head>

<body>
<form action="sub.php" method="post" name="formx1" style="display:none">
  <input type="hidden" name="suppliername"  id="suppliernamesubmit" value="" />


</form>
<div id="loginbox" style="display:none">
<form name="LoginForm" method="post" id="alllogin" action="login.php" onSubmit="return InputCheck(this)">
  <div class="login_title">会员登录</div>
  <div class="login_input">
    <div class="input"><span>账号：</span><span><input name="username" type="text" /></span></div>
    <div class="input"><span>密码：</span><span><input name="password" type="password" /></span></div>
    <input name="headeraction" type="hidden" value="index" />
    <div class="login_input_1 clearfix"><input name="" type="checkbox" value="" id="store1" /><label for="store1">自动登录</label><a onclick="forgetPass()" href="javascript:void(0)">找回密码</a><span style="color:red;display:none" id="passerrorShow" >&nbsp;&nbsp;账号或密码错误</span></div>
    <div class="reg clearfix"><span><input class="login_btn" name="submit" type="image" src="images/login.jpg" /></span><span>还没有账号？</span><a href="reg11.php">立即注册</a></div>
  </div>
</form>
</div>

 
<div id="loginbox1" style="display:none">
<form name="LoginForm" method="post" id="alllogin1" action="login-shop.php" onSubmit="return InputCheck(this)">
  <div class="login_title">店铺登录</div>
  <div class="login_input">
    <div class="input"><span>账号：</span><span><input name="username" type="text" /></span></div>
    <div class="input"><span>密码：</span><span><input name="password" type="password" /></span></div>
    <div class="reg clearfix"><span><input class="login_btn" name="submit" type="image" src="images/login.jpg" /></span><span style="color:red;display:none" id="passerrorShow1" >&nbsp;&nbsp;账号或密码错误</span></div>
  </div>
</form>
</div>
<div id="loginbox3" style="display:none">
  <div class="login_title">忘记密码</div>
  <div class="login_input">
    <div class="inputb"><span>账号：</span><span><input  name="username" id="userzhanghao" type="text" /></span></div>
    <div class="inputc"><span></span><span><input style="width:98px;height:22px;color: #336666;
    font-size: 12px;
    
    line-height: 32px;" id="reSend" value="发送验证码" onclick="sendSMS()" name="password" type="button" /></span></div>
     <div class="inputa"><span>验证码：</span><span><input style="width:98px;" id="yanzhengma" name="password" type="password" /></span></div>
    <div class="reg clearfix"><span><input class="" onclick="phoneCheck()" type="image" src="images/login.jpg" /></span></div>
  </div>

</div>
<?php

if(isset($_SESSION['yesorno'])){
  echo '<input type="hidden" id="mimacheck" value="1" />';


 }else{

echo '<input type="hidden" id="mimacheck" value="0" />';

 } 

if(isset($_SESSION['yesorno1'])){
  echo '<input type="hidden" id="mimacheck1" value="1" />';


 }else{

echo '<input type="hidden" id="mimacheck1" value="0" />';

 } 
 ?>

<div class="top">
  <div class="top_content clearfix"><span class="left"><a href="index.php">欢迎来到外卖网365！</a></span><span class="right">
 
  <?php
    if(isset($_SESSION['username'])){
      if($_SESSION['logintype']=="userlog"){
     echo '<a href="member.php">'.$_SESSION['username'],'欢迎你！</a>';
}elseif ($_SESSION['logintype']=="supplierlog") {
   echo '<a href="shop-xx.php">'.$_SESSION['username'],'欢迎你！</a>';
}
      echo '<a href="login.php?action=logout">登出</a>';
    }else{
    	echo ' <a href="#" id="login">';
      echo '登录';
      echo '</a> / <a href="reg11.php">注册</a>';
    }
  ?>
  <?php  
      if(!isset($_SESSION['username'])  ){
   ?>
  | <a href="#"  id="shoplogin">店铺登录</a></span></div>
  <?php 
    }

   ?>
</div>

<div class="content clearfix">
  <div class="content_logo"><img src="images/logo.png"></div>
  <div class="content_con clearfix">
    <div class="content_con_left left">
    <?php 
    if(isset($_COOKIE["hasvalues"]) && $_COOKIE["hasvalues"] == "true"){ 
    ?>
      <div class="guide">
        <div class="guide_title">常用地址</div>
        <ul class="clearfix add">

    <?php
      $sub_area_query = mysql_query("select * from do_area  order by sort desc limit 4");
            while($subrow = mysql_fetch_array($sub_area_query)){
              ?>
              <li> <span class=""><a href="javascript:suppliername('<?php echo $subrow['name'] ?>')"><?php echo $subrow['name'] ?></a></span><span class="right">></span></li>
            <?php
            }
              mysql_free_result($sub_area_query);
        
    ?>
       </ul>
      </div>
      <div class="guide">
        <div class="guide_title">店铺</div>
        <ul class="clearfix commonshop">
        	<?php 

  			$sub_area_query = mysql_query("select t.*,b.supplier_id,b.stopbusiness,b.preview as bpreview from do_supplier t,do_supplier_location b where b.supplier_id=t.id   order by t.sort limit 9 ");
            while($subrow = mysql_fetch_array($sub_area_query)){
            	$nextstring=$subrow["name"];
            	$tmpstr = "";
            	if(strlen($nextstring)>12){ 
				$hi=utf8Substr($nextstring,0,4);
			$nextstring=$hi."...";


            	}
              echo '<li><a href="sub1.php?supplierid='.$subrow['id'].'"><div><img width="42" height="42"  src="'.$subrow["bpreview"].'"></div><div>'.$nextstring.'</div></a></li>';
            }
              mysql_free_result($sub_area_query);
        
      ?>


        </ul>
      </div>
      <?php 

      } else {
        $sub_adv_query = mysql_query("select * from do_adv where name='首页广告1' ");
        $advrow = mysql_fetch_array($sub_adv_query);
        echo '<div class="guide">';
        echo html_entity_decode($advrow['code']);
        echo '</div>';

      }

    ?>
    </div>

    <div class="content_con_right right">
      <ul class="tabs">
      <?php
        $i = 1 ;
        while($row = mysql_fetch_array($area_query)){
          echo '<li><a href="#tab'.$i.'">',$row['name'],'</a></li>';
          $i++;
        }
        mysql_free_result($area_query);
      ?>
      </ul>
      <div class="tab_container clearfix">
        <?php
          $i = 1 ;
          $area_query = mysql_query("select id from do_area where city_id=16 and pid = 0");
          while($row = mysql_fetch_array($area_query)){
            echo '<ul id="tab'.$i.'" class="tab_content clearfix">';
            $sub_area_query = mysql_query("select name,sort from do_area where pid = ".$row['id']." order by sort desc");
            while($subrow = mysql_fetch_array($sub_area_query)){
             ?>
             <li><a href="javascript:suppliername('<?php echo $subrow['name'] ?>')"><?php 
             $nextstring="";
             $nameStr = $subrow['name'];
             if(strlen($nameStr)>13){ 
                $hi=utf8Substr($nameStr,0,6);
                $nextstring=$hi."...";
              }else{
                $nextstring = $subrow['name'];
              }
             echo $nextstring ?></a></li>
            <?php
            }
            echo '</ul>';
            $i++;
            mysql_free_result($sub_area_query);
          }
          
          mysql_free_result($area_query);
        ?>
      </div>
    </div>
  </div>
</div>

<?php include('bottom.php') ?>
</body>
</html>
